package com.sesame.controller;

import com.sesame.config.UserProperties;
import com.sesame.defin.AbstractController;
import com.sesame.defin.Response;
import com.sesame.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController extends AbstractController {

    @Autowired
    Environment environment;
    @Autowired
    UserProperties userProperties;

    /**
     * http://localhost:8081/test/index?name=1&pwd=aaa
     */
    @RequestMapping("/index")
    public ApiResult index(String name, String pwd) {
        System.out.println("service run .... ");

        User user = new User();
        user.setName(userProperties.getName());
        user.setPwd(userProperties.getSex());
        user.setPort(environment.getProperty("server.port"));

        return success(user);
    }


}
